package com.wlz.splitpackage.customlength;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import lombok.extern.slf4j.Slf4j;

/**
 * @author wlz
 * @date 2022-07-09  3:55 下午
 */
@Slf4j
public class MyMessageEncoder extends MessageToByteEncoder<MyMessageProtocol> {

    @Override
    protected void encode(ChannelHandlerContext ctx, MyMessageProtocol msg, ByteBuf out) throws Exception {
      log.info("MyMessageEncoder encoder 被调用 。。。");
      out.writeInt(msg.getLen());
      out.writeBytes(msg.getContent());
    }
}
